package com.bgs.travelapp.tourNote.mapper;

import com.bgs.travelapp.mapper.BaseMapper;
import com.bgs.travelapp.page.PageRequest;
import com.bgs.travelapp.tourNote.eneity.TourNoteEntity;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * hbx 2022年8月4日09:24:01
 * 前端游记添加展示 (前端)
 */
public interface TourNoteMapper extends BaseMapper<TourNoteEntity> {

    @Select("select id,title,author,cover_id,views,del_flag,create_time,avatar_id from tournote_entity  where del_flag = 0 and open_private = 'true'")
    @Results(
            {@Result(property = "coverId", column = "cover_id"),
                @Result(property = "delFlag", column = "del_flag"),
                @Result(property = "avatarId", column = "avatar_id"),
                @Result(property = "createTime", column = "create_time"),
                @Result(property = "openPrivate", column = "open_private"),
            }
    )
    /**
     * 查询游记信息（前端）
     * hbx 2022年8月12日09:29:58
     */
    List<TourNoteEntity> getTourNoteAll();

    @Select("select id,title,author,cover_id,views,del_flag,create_time,avatar_id from tournote_entity  where open_private = 'true' and del_flag = 0 and city_id=#{cityId}")
    @Results(
            {@Result(property = "coverId", column = "cover_id"),
                    @Result(property = "delFlag", column = "del_flag"),
                    @Result(property = "avatarId", column = "avatar_id"),
                    @Result(property = "createTime", column = "create_time"),
                    @Result(property = "openPrivate", column = "open_private"),
                    @Result(property = "cityId", column = "city_id"),
            }
    )
    /**
     * 根据城市id查询游记信息（前端）
     * hbx 2022年8月12日09:29:37
     */
    List<TourNoteEntity> getTourNoteAllByCityId(Integer cityId);

    @Select("select * from tournote_entity  where del_flag = 0 and user_id = #{userId}")
    @Results(
            {@Result(property = "coverId", column = "cover_id"),
                    @Result(property = "delFlag", column = "del_flag"),
                    @Result(property = "avatarId", column = "avatar_id"),
                    @Result(property = "createTime", column = "create_time"),
                    @Result(property = "textContent", column = "text_content"),
                    @Result(property = "cityId", column = "city_id"),
                    @Result(property = "provinceId", column = "province_id"),
                    @Result(property = "userId", column = "user_id"),

            }
    )
    List<TourNoteEntity> getTourNoteAlls(TourNoteEntity tourNoteEntity,Integer userId);
}
